package com.sensitive.words.controller;

import com.sensitive.words.model.SensitiveWordResult;
import com.sensitive.words.service.SensitiveWordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/sensitiveWords")
public class SensitiveWordController {

    @Autowired
    private SensitiveWordService sensitiveWordService; // 敏感词服务

    @PostMapping("/add")
    public String addSensitiveWord(@RequestParam String word) {
        sensitiveWordService.addSensitiveWord(word);
        return "敏感词添加成功";
    }

    @GetMapping("/find")
    public List<SensitiveWordResult> findSensitiveWords(@RequestParam String text) {
        return sensitiveWordService.findSensitiveWords(text);
    }

    @DeleteMapping("/remove")
    public String removeSensitiveWord(@RequestParam String word) {
        sensitiveWordService.removeSensitiveWord(word);
        return "敏感词删除成功";
    }
}
